package com.be.beadmin.product.mapper;

import com.be.beadmin.product.dto.output.PlantCapacityCalendarEx;
import com.be.beadmin.product.entity.PlantCapacityCalendar;
import com.be.beadmin.service.util.NumberUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @author: Jiaming Zheng
 * @Date: Create in 15:02 2023/8/31
 * @Modified By:
 **/
@Component
public class PlantCapacityCalendarMapperExImplExtend implements PlantCapacityCalendarMapperEx{
    @Override
    public PlantCapacityCalendarEx toEntity(PlantCapacityCalendar dto) {
        if ( dto == null ) {
            return null;
        }

        PlantCapacityCalendarEx plantCapacityCalendarEx = new PlantCapacityCalendarEx();

        if ( dto.getId() != null ) {
            plantCapacityCalendarEx.setId( dto.getId() );
        }
        if ( dto.getCreateTime() != null ) {
            plantCapacityCalendarEx.setCreateTime( dto.getCreateTime() );
        }
        if ( dto.getCreateName() != null ) {
            plantCapacityCalendarEx.setCreateName( dto.getCreateName() );
        }
        if ( dto.getBatchProductCode() != null ) {
            plantCapacityCalendarEx.setBatchProductCode( dto.getBatchProductCode() );
        }
        if ( dto.getRealWorkHour() != null ) {
            plantCapacityCalendarEx.setRealWorkHour(NumberUtil.roundTwo(dto.getRealWorkHour() / 3600) );
        }
        if ( dto.getBatchProductId() != null ) {
            plantCapacityCalendarEx.setBatchProductId( dto.getBatchProductId() );
        }
        if ( dto.getBatchPlanId() != null ) {
            plantCapacityCalendarEx.setBatchPlanId( dto.getBatchPlanId() );
        }
        if ( dto.getBatchPlanCode() != null ) {
            plantCapacityCalendarEx.setBatchPlanCode( dto.getBatchPlanCode() );
        }
        if ( dto.getDate() != null ) {
            plantCapacityCalendarEx.setDate( dto.getDate() );
        }
        if ( dto.getFactoryCode() != null ) {
            plantCapacityCalendarEx.setFactoryCode( dto.getFactoryCode() );
        }
        if ( dto.getFactoryId() != null ) {
            plantCapacityCalendarEx.setFactoryId( dto.getFactoryId() );
        }
        if ( dto.getMemo() != null ) {
            plantCapacityCalendarEx.setMemo( dto.getMemo() );
        }
        if ( dto.getProcessCode() != null ) {
            plantCapacityCalendarEx.setProcessCode( dto.getProcessCode() );
        }
        if ( dto.getProcessId() != null ) {
            plantCapacityCalendarEx.setProcessId( dto.getProcessId() );
        }
        if ( dto.getProcessName() != null ) {
            plantCapacityCalendarEx.setProcessName( dto.getProcessName() );
        }
        if ( dto.getProcessSequence() != null ) {
            plantCapacityCalendarEx.setProcessSequence( dto.getProcessSequence() );
        }
        if ( dto.getProjectCode() != null ) {
            plantCapacityCalendarEx.setProjectCode( dto.getProjectCode() );
        }
        if ( dto.getProjectName() != null ) {
            plantCapacityCalendarEx.setProjectName( dto.getProjectName() );
        }
        if ( dto.getWorkHour() != null ) {
            plantCapacityCalendarEx.setWorkHour( dto.getWorkHour() );
        }
        if ( dto.getFactoryName() != null ) {
            plantCapacityCalendarEx.setFactoryName( dto.getFactoryName() );
        }

        return plantCapacityCalendarEx;
    }
    @Override
    public PlantCapacityCalendar toDto(PlantCapacityCalendarEx entity) {
        if ( entity == null ) {
            return null;
        }

        PlantCapacityCalendar plantCapacityCalendar = new PlantCapacityCalendar();

        if ( entity.getId() != null ) {
            plantCapacityCalendar.setId( entity.getId() );
        }
        if ( entity.getCreateTime() != null ) {
            plantCapacityCalendar.setCreateTime( entity.getCreateTime() );
        }
        if ( entity.getCreateName() != null ) {
            plantCapacityCalendar.setCreateName( entity.getCreateName() );
        }
        if ( entity.getBatchProductId() != null ) {
            plantCapacityCalendar.setBatchProductId( entity.getBatchProductId() );
        }
        if ( entity.getBatchProductCode() != null ) {
            plantCapacityCalendar.setBatchProductCode( entity.getBatchProductCode() );
        }
        if ( entity.getBatchPlanId() != null ) {
            plantCapacityCalendar.setBatchPlanId( entity.getBatchPlanId() );
        }
        if ( entity.getBatchPlanCode() != null ) {
            plantCapacityCalendar.setBatchPlanCode( entity.getBatchPlanCode() );
        }
        if ( entity.getProcessSequence() != null ) {
            plantCapacityCalendar.setProcessSequence( entity.getProcessSequence() );
        }
        if ( entity.getProcessId() != null ) {
            plantCapacityCalendar.setProcessId( entity.getProcessId() );
        }
        if ( entity.getProcessName() != null ) {
            plantCapacityCalendar.setProcessName( entity.getProcessName() );
        }
        if ( entity.getProcessCode() != null ) {
            plantCapacityCalendar.setProcessCode( entity.getProcessCode() );
        }
        if ( entity.getFactoryCode() != null ) {
            plantCapacityCalendar.setFactoryCode( entity.getFactoryCode() );
        }
        if ( entity.getFactoryName() != null ) {
            plantCapacityCalendar.setFactoryName( entity.getFactoryName() );
        }
        if ( entity.getFactoryId() != null ) {
            plantCapacityCalendar.setFactoryId( entity.getFactoryId() );
        }
        if ( entity.getProjectCode() != null ) {
            plantCapacityCalendar.setProjectCode( entity.getProjectCode() );
        }
        if ( entity.getProjectName() != null ) {
            plantCapacityCalendar.setProjectName( entity.getProjectName() );
        }
        if ( entity.getDate() != null ) {
            plantCapacityCalendar.setDate( entity.getDate() );
        }
        if ( entity.getWorkHour() != null ) {
            plantCapacityCalendar.setWorkHour( entity.getWorkHour() );
        }
        if ( entity.getRealWorkHour() != null ) {
            plantCapacityCalendar.setRealWorkHour( entity.getRealWorkHour() );
        }
        if ( entity.getMemo() != null ) {
            plantCapacityCalendar.setMemo( entity.getMemo() );
        }

        return plantCapacityCalendar;
    }

    @Override
    public List<PlantCapacityCalendarEx> toEntity(List<PlantCapacityCalendar> dtoList) {
        if ( dtoList == null ) {
            return null;
        }

        List<PlantCapacityCalendarEx> list = new ArrayList<PlantCapacityCalendarEx>( dtoList.size() );
        for ( PlantCapacityCalendar plantCapacityCalendar : dtoList ) {
            list.add( toEntity( plantCapacityCalendar ) );
        }

        return list;
    }

    @Override
    public List<PlantCapacityCalendar> toDto(List<PlantCapacityCalendarEx> entityList) {
        if ( entityList == null ) {
            return null;
        }

        List<PlantCapacityCalendar> list = new ArrayList<PlantCapacityCalendar>( entityList.size() );
        for ( PlantCapacityCalendarEx plantCapacityCalendarEx : entityList ) {
            list.add( toDto( plantCapacityCalendarEx ) );
        }

        return list;
    }

}
